package hk.security;
import java.io.IOException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.*;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.*;

public class AuthOkHandler  implements AuthenticationSuccessHandler  {
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, 
    	Authentication authentication) throws IOException, ServletException {
    	User userDetail = (User) authentication.getPrincipal();  //注意这个 User是系统自带的类型
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().print("登录成功,用户名:"+userDetail.getUsername()+" 用户内容:"+userDetail);
    }
}
